import httpCreator from '../assets/js/common-http'
let http = httpCreator()
let ohttp = httpCreator('/onlineapi')

// 获取城市列表
export function getCityList (param, query) {
  return new Promise((resolve, reject) => {
    http.get('/data/city.json').then(resolve).catch(reject)
  })
}

// 获取正在热映数据
export function getNowPlaying(param, query) {
  return new Promise((resolve, reject) => {
    ohttp.get('/movieOnInfoList', { params: query }).then(resolve).catch(reject)
  })
}
// 获取即将上映数据
export function getComingSoon(param, query) {
  return new Promise((resolve, reject) => {
    ohttp.get('/movieComingList', { params: query }).then(resolve).catch(reject)
  })
}
// 搜索电影数据
export function searchMovie(param, query) {
  return new Promise((resolve, reject) => {
    ohttp.get('/searchList', { params: query }).then(resolve).catch(reject)
  })
}
// 获取影院列表
export function getCinemaList(param, query) {
  return new Promise((resolve, reject) => {
    ohttp.get('/cinemaList', { params: query }).then(resolve).catch(reject)
  })
}
// 获取当前城市定位
export function getCityLocation(param, query) {
  return new Promise((resolve, reject) => {
    ohttp.get('/getLocation').then(resolve).catch(reject)
  })
}
// 获取电影的详情
export function getMovieDetail(param, query) {
  return new Promise((resolve, reject) => {
    ohttp.get('/detailmovie', { params: query }).then(resolve).catch(reject)
  })
}
